<template>
  <div>
    <el-badge :value="total" class="item" v-if="total >0">
    <i class="el-icon-message-solid" @click="goto" />
    </el-badge>
    <i v-else class="el-icon-bell" @click="goto" />
  </div>
</template>

<script>
import { apiDs } from "@/api/openapi";
export default {
  name: 'RuoYiMsg',
  data() {
    return {
      total: 0
    }
  },
  created() {
    this.getUnread();
    setInterval(this.getUnread, 1000 * 60);
  },
  methods: {
    getUnread() {
      apiDs('sys_msg_unread').then(response=>{
        this.total  = response.data;
      })
    },
    goto() {
      this.$tab.openPage("我的消息", '/my/msg');
    }
  }
}
</script>

<style>
.item {
  margin-top: 5px;
  margin-right: 40px;
}
</style>